//
//  WithdrawView.m
//  DA_V
//
//  Created by 周季阳 on 15/5/11.
//  Copyright (c) 2015年 zhouhai. All rights reserved.
//

#import "WithdrawView.h"
#import "InterFace.h"
#import "UIViewAdditions.h"
@implementation WithdrawView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        [self createrOffLineUI:CGRectMake(self.zDate.left, 0, 1, self.frame.size.height)];
        [self createrOffLineUI:CGRectMake(self.zDate.left, 0, SCREEN_WIDTH-20, 1)];
        
        self.zDate = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0.3125*SCREEN_WIDTH, self.frame.size.height)];
        self.zDate.textColor = [self colorWithHexString:@"#9C9C9C"];
        self.zDate.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.zDate];
        
        
        
        [self createrOffLineUI:CGRectMake(self.zDate.right, 0, 1, self.frame.size.height)];
        
        self.zTime = [[UILabel alloc] initWithFrame:CGRectMake(_zDate.right, 0, 0.21875*SCREEN_WIDTH, self.frame.size.height)];
        self.zTime.textColor = [self colorWithHexString:@"#9C9C9C"];
        self.zTime.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.zTime];
        
        [self createrOffLineUI:CGRectMake(self.zTime.right, 0, 1, self.frame.size.height)];
        
        self.zPrice = [[UILabel alloc] initWithFrame:CGRectMake(self.zTime.right, 0, 0.1875*SCREEN_WIDTH, self.frame.size.height)];
        self.zPrice.textColor = [self colorWithHexString:@"#9C9C9C"];
        self.zPrice.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.zPrice];
        
        [self createrOffLineUI:CGRectMake(self.zPrice.right, 0, 1, self.frame.size.height)];
        
        if (SCREEN_WIDTH == 320) {
            self.zState = [[UILabel alloc] initWithFrame:CGRectMake(_zPrice.right, 0, 0.21875*SCREEN_WIDTH, self.frame.size.height)];
        }else if (SCREEN_WIDTH == 375){
            self.zState = [[UILabel alloc] initWithFrame:CGRectMake(_zPrice.right, 0, 0.22575*SCREEN_WIDTH, self.frame.size.height)];
        }else{
            self.zState = [[UILabel alloc] initWithFrame:CGRectMake(_zPrice.right, 0, 0.232*SCREEN_WIDTH, self.frame.size.height)];
        }
        
        self.zState.textColor = [self colorWithHexString:@"#9C9C9C"];
        self.zState.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_zState];
        [self createrOffLineUI:CGRectMake(self.zState.right, 0, 1, self.frame.size.height)];
        [self createrOffLineUI:CGRectMake(self.zState.right, 0, 1, self.frame.size.height)];
        
        
        UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-1, self.frame.size.width, 1)];
        line.backgroundColor = [UIColor grayColor];
        line.alpha = 0.4;
        [self addSubview:line];
        
        
    }
    return self;
}
-(void)createrOffLineUI:(CGRect)rect{
    UIView *lines = [[UIView alloc] initWithFrame:rect];
    lines.backgroundColor = [UIColor colorWithRed:179/255.0 green:179/255.0 blue:179/255.0 alpha:1];
    [self addSubview:lines];
}
//传入字符串返回RGB
- (UIColor *) colorWithHexString: (NSString *)color
{
    NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
    
    // String should be 6 or 8 characters
    if ([cString length] < 6) {
        return [UIColor clearColor];
    }
    
    // strip 0X if it appears
    if ([cString hasPrefix:@"0X"])
        cString = [cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"])
        cString = [cString substringFromIndex:1];
    if ([cString length] != 6)
        return [UIColor clearColor];
    
    // Separate into r, g, b substrings
    NSRange range;
    range.location = 0;
    range.length = 2;
    
    //r
    NSString *rString = [cString substringWithRange:range];
    
    //g
    range.location = 2;
    NSString *gString = [cString substringWithRange:range];
    
    //b
    range.location = 4;
    NSString *bString = [cString substringWithRange:range];
    
    // Scan values
    unsigned int r, g, b;
    [[NSScanner scannerWithString:rString] scanHexInt:&r];
    [[NSScanner scannerWithString:gString] scanHexInt:&g];
    [[NSScanner scannerWithString:bString] scanHexInt:&b];
    
    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:1.0f];
}


@end
